package sigmacinema.ui.tapestry.controller;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry.html.BasePage;

import sigmacinema.entity.Seat;
import sigmacinema.service.SigmaCinemaService;
import com.javaforge.tapestry.spring.annotations.InjectSpring;
import org.apache.tapestry.annotations.Bean;
import org.apache.tapestry.valid.ValidationDelegate;

public abstract class SeatController extends BasePage{
	@InjectSpring("SigmaCinemaService")
	 public abstract SigmaCinemaService getSigmaCinemaService();
        
	 @Bean
        public abstract ValidationDelegate getDelegate();
	 private Seat seat = new Seat();
	 private List<Seat> listSeat= new ArrayList<Seat>();

	public Seat getSeat() {
		return seat;
	}

	public void setSeat(Seat seat) {
		this.seat = seat;
	}
	
	public List<Seat> getListSeat() {
		listSeat=getSigmaCinemaService().findAllSeat();
		return listSeat;
	}

	public void setListSeat(List<Seat> listSeat) {
		this.listSeat = listSeat;
	}

	public String save(){
            ValidationDelegate delegate = getDelegate();
            if(delegate.getHasErrors()){
                return null;
            }else{
                getSigmaCinemaService().saveSeat(seat);
		return "admin/ViewSeat";
            }
		
	}
}
